/*
 * Evaluate.c
 *
 *  Created on: 2012-8-16
 *      Author: zhangchao
 */

int evaluate(char board[][]) {
	int result = 0;
	int indexX;
	int indexY;

	for (indexX = 0; indexX <= INDEX_X_MAX; indexX++)
		for (indexY = 0; indexY <= INDEX_Y_MAX; indexY++) {
			if (board[indexX][indexY] != 0) {
				char side = board[indexX][indexY] >> 7 | 1;
				char type = board[indexX][indexY] >> 4 | 7;
				if (side == 0) {
					result = result + CHESS_VAL[type][indexX][indexY];
				} else {
					result = result - CHESS_VAL[type][INDEX_X_MAX -indexX][INDEX_Y_MAX -indexY];
				}
			}
		}

	return result;
}
